package com.ywk.base.dataStructure.binarytree;

public class BinaryTreeDemo {

	public static void main(String[] args) {
		String s="9,3,4,#,#,1,#,#,2,#,6,#,#";
		int count=0;
		for(String st:s.split(",")) {
			count++;
		}
		System.out.println(count);
		System.out.println(s.length());
	}
}

class BinaryTree{
	private HeroNode root;
	
	public void setRoot(HeroNode root) {
		this.root=root;
	}
	
	public void preOrder() {
		if(root!=null) {
			root.preOrder();
		}else {
			System.out.println("二叉树为空");
		}
	}
}

class HeroNode{
	private int no;
	private String name;
	public HeroNode left;
	public HeroNode right;
	
	public HeroNode(int no, String name) {
		super();
		this.no = no;
		this.name = name;
	}

	public int getNo() {
		return no;
	}

	public void setNo(int no) {
		this.no = no;
	}


	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public HeroNode getLeft() {
		return left;
	}

	public void setLeft(HeroNode left) {
		this.left = left;
	}
	
	public HeroNode getRight() {
		return right;
	}

	public void setRight(HeroNode right) {
		this.right = right;
	}

	@Override
	public String toString() {
		return "HeroNode [no=" + no + ", name=" + name + "]";
	}
	
	//前序遍历
	public void preOrder() {
		System.out.println(this);
		if(this.left!=null) {
			this.left.preOrder();
		}
		if(this.right!=null) {
			this.right.preOrder();
		}
	}
	
	//中序遍历
	public void infixOrder() {
		if(this.left!=null) {
			this.left.infixOrder();
		}
		System.out.println(this);
		if(this.right!=null) {
			this.right.infixOrder();
		}
	}
	
	//后续遍历
	public void postOrder() {
		if(this.left!=null) {
			this.left.postOrder();
		}
		if(this.right!=null) {
			this.right.postOrder();
		}
		System.out.println(this);
	}
}